import { getDeptList } from "@/api/modules/dept";
import TreeFilter from "@/components/TreeFilter/index.vue";
import { defineComponent } from "vue";
export default defineComponent({
	props: {
		detail: {
			type: Object,
			default() {
				return {};
			}
		},
		multiple: {
			type: Boolean,
			default() {
				return false;
			}
		}
	},
	emits: ["change"],
	setup(props, { emit }) {
		const change = (node: any) => {
			props.detail.deptId = node.id;
			props.detail.deptName = node.deptName;
			emit("change", node);
		};
		// dataCallback 是对于返回的表格数据做处理，
		const dataCallback = (data: any) => {
			return data.records.children;
		};
		return () => {
			return (
				<TreeFilter
					requestApi={getDeptList}
					id="id"
					label="deptName"
					dataCallback={dataCallback}
					defaultValue={props.detail.deptId}
					multiple={props.multiple}
					onChange={(data: any) => change(data)}
				/>
			);
		};
	}
});
